#ifndef __TASKQUEUE_H__
#define __TASKQUEUE_H__
#include <queue>
#include <mutex>
#include <condition_variable>
#include <functional>

using namespace std;


using ElemType = function<void()>;

class TaskQueue{
public:
    TaskQueue(size_t capacity);
    ~TaskQueue();

    void push(ElemType && taskcb);
    ElemType pop();
    bool full() const;
    bool empty() const;
    void wakeup();
private:
    size_t _capacity;
    queue<ElemType> _taskQue;
    mutex _mutex;
    condition_variable _notFull;
    condition_variable _notEmpty;
    bool _flag;
};


#endif

